# 搬家具
"""
房⼦类
实例属性
房⼦地理位置
房⼦占地⾯积
房⼦剩余⾯积
房⼦内家具列表
实例⽅法
容纳家具
显示房屋信息
"""


class House():
    def __init__(self, position, area, last_area):
        """
        实例属性
        房⼦地理位置
        房⼦占地⾯积
        房⼦剩余⾯积
        房⼦内家具列表
        """
        # 
        # 房⼦地理位置
        self.position = position
        # 房⼦占地⾯积
        self.area = area
        # 房⼦剩余⾯积
        self.last_area = last_area
        #         房⼦内家具列表
        self.furniture = []
        pass

    """
    实例⽅法
    容纳家具
    显示房屋信息
    """

    def __str__(self):
        return f'这个房子地理位置:{self.position},占地面积:{self.area},剩余面积:{self.last_area},' \
               f'房子类家具列表:{[i for i in self.furniture]}'

    def add_furniture(self, furniture):
        if self.last_area >= furniture.space:
            self.last_area -= furniture.space
            self.furniture.append(furniture.name)
            pass
        else:
            print(f'空间不足,放不下')
        pass

    pass


"""
家具类
家具名称
家具占地⾯积
"""


class Furniture():
    def __init__(self, name, space):
        self.name = name
        self.space = space
        print(f'家具大小:{space},家具名称:{name}')
        pass

    def __str__(self):
        return f'家具大小:{self.space},家具名称:{self.name}'

    pass


# 家具
furniture = Furniture('家具1', 5)
print(furniture)
# 这个
house = House('中国深圳', 100, 10)
house.add_furniture(furniture)
house.add_furniture(furniture)
house.add_furniture(furniture)
print(house)
